package demo.ejs.result;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.util.ValueStack;

public class XmlResult implements Result {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void execute(ActionInvocation invocation) throws Exception {

		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/plain; charset=UTF-8");  
        final PrintWriter out = response.getWriter();  
        try {  
            final ValueStack stack = invocation.getStack();  
            
//          out.println("Hello result");
            out.println("<Grid><Body><B>");
            MyDTO dto1=new MyDTO("d1","Lucy",998.0,"Amazon",100);
            MyDTO dto2=new MyDTO("d2","Jack",998.0,"360",100);
            MyDTO dto3=new MyDTO("d3","Lydia",998.0,"Ebuy",100);
            out.println(dto1.toXMLString());
            out.println(dto2.toXMLString());
            out.println(dto3.toXMLString());
            out.println("</B></Body></Grid>");
            
        } catch (Exception e) {  
             
        }  
        out.close();
	}

}
